package com.aoxon.cargo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.aoxon.cargo.R;
import com.aoxon.cargo.cache.keyCache;
import com.aoxon.cargo.loader.FileLoader;
import com.aoxon.cargo.shared.SupIndexShared;

/**
 * 供应商设置界面
 * 
 * @author ZZJ
 * 
 */
public class SupSettingActivity extends BaseActivity {

	private ImageView ivReturnButton;
	private TextView tvExitAccountButton;
	private TextView tvTitle;

	private RelativeLayout rlSettingOfStore;
	private RelativeLayout rlRevampPassword;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sup_setting);

		ivReturnButton = (ImageView) findViewById(R.id.ivPublicTitleReturn);
		tvTitle = (TextView) findViewById(R.id.tvPublicTiTle);
		tvExitAccountButton = (TextView) findViewById(R.id.tvSupplierExitAccountButton);

		rlSettingOfStore = (RelativeLayout) findViewById(R.id.rlSupplierSettingOfStore);
		rlRevampPassword = (RelativeLayout) findViewById(R.id.rlSupplierRevampPassword);

		tvTitle.setText("设置");
		ivReturnButton.setOnClickListener(myClickListener);
		tvExitAccountButton.setOnClickListener(myClickListener);
		rlSettingOfStore.setOnClickListener(myClickListener);
		rlRevampPassword.setOnClickListener(myClickListener);

	}


	/**
	 * 系统按键的设置
	 * *****************************************************************************************************************************************/

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			Intent intent = new Intent(getBaseContext(), SupIndexActivity2.class);
			startActivity(intent);
			this.finish();
			return false;
		}
		return false;
	}

	/**
	 * 设置控件的点击监听
	 */
	OnClickListener myClickListener = new OnClickListener() {
		private Intent intent = null;

		@Override
		public void onClick(View v) {

			switch (v.getId()) {

			case R.id.ivPublicTitleReturn:
				intent = new Intent(getBaseContext(), SupIndexActivity2.class);
				startActivity(intent);
				SupSettingActivity.this.finish();
				break;

			case R.id.tvSupplierExitAccountButton:
				intent = new Intent(getBaseContext(), SupLoginActivity.class);
				SupIndexShared.clear();
				keyCache.clear();
				startActivity(intent);
				new FileLoader(0, 0, false).clearCache();
				SupSettingActivity.this.finish();
				break;

			case R.id.rlSupplierSettingOfStore:
				intent = new Intent(getBaseContext(),
						SupFillInfo1Activity.class);
//						SupStoreInformationActivity.class);
				startActivity(intent);
				SupSettingActivity.this.finish();
				break;

			case R.id.rlSupplierRevampPassword:
				intent = new Intent(getBaseContext(),
						SupRevampPasswordActivity.class);
				startActivity(intent);
				SupSettingActivity.this.finish();
				break;

			default:
				break;
			}
		}
	};

}
